#coding:utf8
from db_base.TournamentServer import TM

def getTeamType():
	game_dict = dict()
	game_type_d = TM.getByfilter('team_type',dict(delete_flag = '\x00'))
	for game in game_type_d:
		game_dict[game.get('id')] = game.get('t_type')
	return game_dict

def GetEventType():
	event_type_dict = dict()
	event_type_d = TM.getByfilter('events_type',dict())
	for game in event_type_d:
		event_type_dict[game.get('id')] = game.get('type_name')
	return event_type_dict

def GetGameData(icon = False):
	game_dict = dict()
	game_datas = TM.getByfilter('game',dict(delete_flag = 0))
	for _game in game_datas:
		if icon:
			game_dict[_game.get('id')] = _game.get('icon')
		else:	
			game_dict[_game.get('id')] = _game.get('game_name')
	return game_dict

def isint(obj):
    try:
        obj = int(obj)
    except Exception as e:
        return dict(code = 0,msg= '非法操作')

